<?php

namespace App\VO\WechantPayment\MetaInfo;

use App\BO\Wechat\Meta\WechatPayResultMeta;
use App\BO\Wechat\WechatSign;

class PayInfoFactory
{
    public static function getPayInfo(WechatPayResultMeta $meta)
    {
        $payInfo = new PayInfo();
        $payInfo->setAppId($meta->getAppId());
        $payInfo->setNonceStr($meta->getNonceStr());
        $payInfo->setPackage($meta->getPackage());
        $payInfo->setTimeStamp(strval(time()));

        $key = config('wechat.payment.default.key');
        $paySign = WechatSign::generateSign($key, $meta);
        $payInfo->setPaySign($paySign);

        return $payInfo;
    }
}
